﻿
using System;
using System.Diagnostics;
using System.Windows;

namespace 外观模式
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    /// 
    /// 外观模式把操作同一对象的方法，统一起来放到一个类中，平常也用
    public partial class MainWindow : Window
    {
        //private const int _amount = 12000;
        //private bool _eligible = true;
        public MainWindow()
        {
            InitializeComponent();
            //没有使用外观模式

            //var bank = new Bank();
            //var loan = new Loan();
            //var credit = new Credit();
            //var customer = new Customer("Ann McKinsey");

            //if (!bank.HasSufficientSavings(customer, _amount))
            //{
            //    _eligible = false;
            //}
            //else if (!loan.HasNoBadLoans(customer))
            //{
            //    _eligible = false;
            //}
            //else if (!credit.HasGoodCredit(customer))
            //{
            //    _eligible = false;
            //}
            //Debug.WriteLine("\n" + customer.Name + @" has been " + (_eligible ? "Approved" : "Rejected"));

            //使用外观模式
            var mortgage = new Mortgage();
            var customer = new Customer("Ann McKinsey");
            var eligable = mortgage.IsEligible(customer, 125000);
            Debug.WriteLine("\n" + customer.Name + @" has been " + (eligable ? "Approved" : "Rejected"));

        }
    }
}
